package com.igoal.dto;

import java.io.Serializable;
import java.util.Date;

import com.igoal.entity.Image;
import com.igoal.entity.UserStatus;
import com.igoal.utils.CalendarUtils;
import com.igoal.utils.SynchronizeAttributeWithOther;
import com.igoal.utils.SynchronizeDirection;

public class UserStatusDTO extends BaseDTO<UserStatus> implements Serializable {
	private static final long serialVersionUID = 4596214172371754245L;
	private String userStatus;
	private String imgURL;

	public String getUserStatus() {
		return userStatus;
	}

	public void setUserStatus(String userStatus) {
		this.userStatus = userStatus;
	}

	public String getImgURL() {
		return imgURL;
	}

	public void setImgURL(String imgURL) {
		this.imgURL = imgURL;
	}

	@SynchronizeAttributeWithOther(direction = SynchronizeDirection.FROM, value = "smiley")
	public void initUserStatusFromEntity(Object entity) {
		if (entity != null && entity instanceof Image) {
			Image smiley = (Image) entity;
			this.imgURL = smiley.getImageUrl();
		}
	}
	
	@SynchronizeAttributeWithOther(direction = SynchronizeDirection.FROM, value="updateDate")
	public void initUpdatedSince(Object obj){
		if(obj != null && obj instanceof Date){
			Date date = (Date) obj;
			updateDate = CalendarUtils.calculateMinutesDifferentBeforeNow(date);
		}
	}
}
